#include <fstream>
#include <iostream>
#include "rafi.h"

int main()
{
    std::ifstream lIfstream;
    lIfstream.open("D:\\gw2work\\ahom-cloud\\gw2\\gw2\\RafiOutput\\encodedFile.tmp", std::ios::binary);

    lIfstream.seekg(0, std::ios::end);
    int insize = lIfstream.tellg();
    lIfstream.seekg(0, std::ios::beg);

    unsigned char *input = new unsigned char [insize];
    lIfstream.read(reinterpret_cast<char*>(input),insize);
    lIfstream.close();

    unsigned char *output(0);
    int outsize;

    UnpackGWDat(input, insize, output, outsize);

    if (output)
    {
        std::cout << "Success!" << std::endl;
        std::cout << "Outsize: " << outsize << std::endl;

        std::ofstream lOfstream;
        lOfstream.open("D:\\gw2work\\ahom-cloud\\gw2\\gw2\\RafiOutput\\resultFile.tmp", std::ios::binary);
        lOfstream.write(reinterpret_cast<char*>(output), outsize);
        lOfstream.close();
    }
    else
    {
        std::cout << "Failure!" << std::endl;
    }


    return 0;
}
